<template>
  <van-button @click="handleLogout">退出登陆</van-button>
</template>

<script>
import { mapActions, mapGetters,mapState } from 'vuex'
import { Dialog } from 'vant'

export default {
  methods: {
    ...mapActions(["Logout"]),
    
    handleLogout() {
      const that = this

      Dialog.confirm({
        title: '提示',
        message: '真的要注销登录吗？',
      })
        .then(() => {
          // on confirm
          return that.Logout({}).then(() => {
            // update-begin author:wangshuai date:20200601 for: 退出登录跳转登录页面
            that.$router.push({ path: '/user/login' });
            window.location.reload()
            // update-end author:wangshuai date:20200601 for: 退出登录跳转登录页面
          }).catch(err => {
            that.$message.error({
              title: '错误',
              description: err.message
            })
          })
        })
        .catch(() => {
          // on cancel
        });
    },
  }
}
</script>

<style>

</style>